import React from 'react'
// import Hello from './component/Hello/Hello.jsx'
// import Welcome from './component/Welcome/Welcome.jsx'
// import TodoList from './component/TodoList/TodoList.jsx'
import Loyout from './pages/body/body.jsx'
import axios from 'axios'
import './App.css'

class App extends React.Component {
  render() {
    return (
      <div className="app">
        {/* <Hello /> */}
        {/* <Welcome /> */}
        {/* <TodoList /> */}
        <Loyout />
      </div>
    )
  }

  componentDidMount(){
    this.req()
  }

  req = () => {
    axios.get('/api/try/ajax/json_demo.json').then(res => {
      console.log('xhr请求成功', res.data);
    }).catch(err => {
      console.log('xhr请求失败', err);
    })

    // 弊端一：低版本浏览器咱不支持
    fetch('/api/try/ajax/json_demo.json', {
      method: 'get'
    }).then(response => {
      // 弊端二：不管请求成功或者失败都会走先第一个.then
      return response.json()
    }).then(res => {
      console.log('fetch请求成功', res);
    }).catch(err => {
      console.log('fetch请求失败', err);
    })
  }
}

export default App;
